#ifndef _BUTTON_H_
#define _BUTTON_H_

#include "Object.h"

//Forward declarations to reduce dependencies
class TextObject;
class Picture;

/**
	An object that executes a given script command when clicked or key pressed. Contains a picture or text inside
	to denote what script will be called
*/
class Button: public Object {
	TextObject* text;		//The text object if we hold one
	Picture* pic;			//The picture object if we hold one
	std::string command;	//The command to execute when notified

	void executeCommand();	//Execute the command
	void resize();			//Resizes the button based on the dimensions of the inside object
	
	//No copying...
	Button(const Button&);
	Button& operator=(const Button&);

public:
	Button(const std::string& command = "");
	virtual ~Button();
	
	void draw(unsigned long timestamp);
	
	void onLeftClick();
	void onKeyPress();
	void onRollOver();
	void onRealign(float minX, float maxX, float minY, float maxY);
	
	//Setters for if the child is a text object
	void setText(const std::string& str);
	void setFont(const std::string& fnt);
	void setSize(int size);
	
	void enable();
	void disable();
	
	void loadFromXML(ticpp::Node* node, int Z, Frame*);
};

#endif
